#!D:\python_workspace\python35 python
#coding:utf-8
# __author__ = 'zhangwentao'

print(abs(100))
print(abs(-20))

print(max(100, 30))

print(hex(100))

def my_abs(x):
    if not isinstance(x, (int, float)):
        raise TypeError("data wrong")
    if x > 0:
        return x
    else:
        return 0

print(my_abs(12))

class Student(object):

#__init__ 创建实例时调用该方法 相当于java中的构造函数
    def __init__(self, name, score):
        self.name = name
        self._score = score

    def print_info(self):
        print("name: %s; score: %s" % (self.name, self._score))

# 销毁实例时调用该方法
    def __del__(self):
        pass

a = Student("zhang", "95")

a.score = "30"

a.print_info()

import sqlite3
# conn = sqlite3.connect("test.db")
# cursor = conn.cursor()
# cursor.execute("create table user (id varchar(20) primary key, name varchar(20))")
# cursor.execute('insert into user (id, name) values (\'1\', \'Michael\')')
# print(cursor.rowcount)
# cursor.close()
# conn.commit()
# conn.close()

conn = sqlite3.connect("test.db")
cursor = conn.cursor()
cursor.execute("select * from user where id=?", ("1", ))
value = cursor.fetchall()
print(value)

print(issubclass(Student, object))

import time

def foo(a):
    def appFoo(b):
        return (b+a)
    return appFoo

print(foo("3")("l"))

def action_pro(n):
    def warpper(x):
        return(n(x) * x)
    return(warpper)

@action_pro #用action_pro函数把action包装成warpper
def action(x):
    return x

print(action(5))
